Part Number Hot Search : 
BJ15A HD7400 IRFZ44Z EL100C TSM4459 OP37BZ DBL155G 3100B
Product Description
Full Text Search
 

To Download AN1548 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  1/10 author: g. pitruzzello april 2002 AN1548 application note high resolution single slope conversion with the analog comparator of the st52x440 introduction the following application shows the operation of the analog comparator of the st52x440 microcontroller along with some examples of various resolution measures with varying conversions from 8, 10 and 12 bits. preliminary the st52_440 includes an analog comparator among its peripherals that allows the user to make use of it as a single slope analog to digital converter. in a/d mode the user may choose either to insert an external capacitor to pin cs or to connect to an ex- ternal signal to generate ramp. the internal current generator, utilized to charge the capacitor provides 7 possible current values from 0 to 70 m a with steps of 10 m a. the capacitor should have a low voltage coefficient for optimum results. the optimum linearity in conver- sion can be obtained if the voltage level on the selected input channel does not exceed a maximum of 3v. a/d conversion theory the a/d slope is formed when a constant current drives a capacitor. according to the basic capacitor the- ory, the voltage across this capacitor is described by the following equation: [1] since the current i(t) is constant, the former equation is reduced to the following equation: [2] this relationship describes a basic linear voltage ramp. the analog to digital conversion is obtained by measuring the time from the beginning of the linear ramp (t0) to time (t1), in which the voltage across the capacitor equals the analog input voltage to be converted. time is measured by a digital counter circuit. therefore, the delta time value (t1-t2) represents the magnitude of the analog voltage being converted. in this application note, the delta time value measured will simply be referred to as the n for the particular analog voltage being converted. figure 1. linear voltage ramp a/d conversion vt () 1 c --- - xit () t d t0 tl = vt 1 () vt 0 () C i c --- - xt 1 t 0 C () =
AN1548 - application note 2/10 the magnitude of the analog voltage measured can be determined if the capacitance and the charging current are known. however, these values cannot be determined exactly. therefore, a reference voltage that is known is used instead. this reference voltage is supplied by a very stable circuit known as a band- gap reference. the analog input voltage is determined ratiometrically by performing two successive a/d conversions: the first on the analog input voltage and the second on the reference voltage. the analog voltage being measured can be calculated by using the equation below: [3] where: n in = a/d count value for selected input n bg = a/d count value for bandgap reference k bg = absolute voltage value of the bandgap reference voltage. equation (3) assumes that the starting voltage of the linear ramp v(t 0 ) in both the analog input and the reference voltage conversion is zero. however, the capacitor cannot be discharged completely from the prior conversion and a few millivolts worth of charge (referred to as offset voltage), may remain on the ca- pacitor. this effect is called capacitor dielectric absorption and varies depending on the capacitors dielec- tric material, voltage to which it was charged during the last charge cycle and the amount of time the capacitor has had to discharge. while teflon capacitors exhibit the lowest dielectric absorption, polysty- rene and polyethylene are also excellent. ceramic, glass and mica are fair, while tantalum and electrolytic types are poor choices for a/d applications. additionally, the comparator (that compares the ramp voltage to the input voltage and stops the timer when the voltage are equal) usually has a few millivolts of offset error in its comparison. this comparator offset voltage adds (or subtracts) to the dielectric absorption offset. finally, the counter that times the conversion may have a very small constant turn-on or turn-off delay that affects the measurement in the same manner as offset voltage. software implementation an example of the a/d conversion at a 10 bit resolution is provided below by explaining in detail the con- figuration mask of the analog comparator of the st52x440 microcontroller. further in this application note, the linearity measures performed as the frequency varies will be shown. setting clock master first of all, the working frequency of the microchip needs to be established, which in this case is set to 10 mhz (see figure 2) afterwards, the port pins must be configured (see figure 3). figure 2. clock master configuration v in n in n bg ---------- - xk bg =
3/10 AN1548 - application note figure 3. port pin configuration setting device configuration in this application, the digital outputs are represented by all of port a (pa0-pa7) and the two pins of port c (pc0 and pc1). the analog input to which we will apply a variable tension from 0v to 3v is pin pb0, configured in the alternate function ac0, one of the possible analogic inputs. pin pb7 is set as cs to ap- ply the capacitor (10nf to 1000nf are recommended) for the ramp generation. lastly, by setting pin pb6 as bg, the bandgap is mode available. once the value of the capacitor to be inserted is established, the analog comparator mask can be configured (see figure 4). figure 4. analog comparator configuration
AN1548 - application note 4/10 setting analog comparator the first thing that has to be set in the analog comparator of the st52x440 is the working mode .after- wards, the type of conversion to be performed may be selected. repetitive mode offers a cyclic a/d con- version, while sequential mode only provides a sequential a/d conversion for all the analog channels that are configured. obviously, if only one channel is configured sequential mode wont be available. the user may also set the number of times for which a conversion can be performed for the same channel, from 1 to 3. this number represents the group of conversions, which the interrupt source check boxes refers to. for example, lets suppose we have two analog channels, aco and ac1 and we set the con- version per channel for each one of these on 3. by selecting the option end of each conversion an interrupt will occcur at the end of each single analog-digital conversion. instead, by selecting the option end of each conversion sequence an interrupt will occur at the end of the last analog channel, ac1. the options contained in the used reference signal offer the possibility of being able to insert a channel of reference that can be either mass or bandgap in the a/d conversion. for example, by setting the option bg , the conversion of the signal applied in input will occur alternatively with the conversion of the band- gap. by setting none , only the analog conversion signal in input will be performed. the options of the counting direction section represent the way in which the calculation will begin the ramp conversion. for example, by setting the resolution to 8 bits with the counting direction on down the following result will be obtained: and viceversa, if the option up is selected the counter will begin from zero and the following result will be ob- tained: and another possibility that is offered with the st52x440 microcontroller is the application of a ramp of voltage as a replacement of the external capacitor. this work modality can be set in the ramp section, in which the user can choose the positive or negative slope of the input ramp. if this working mode is chosen in- stead of the external capacitor, we have to keep in mind that pin pa3 in alternate function acstrt must be used as a timer start, in order to syncronize itself with the beginning of the ramp. particular attention needs to be given to the three list boxes which configure the following: charge current (ua) = the current generator used to charge the capacitor resolution = the resolution with which to perform the a/d conversions capacitor (nf) = the value of the capacitor to be connected to the micro prescaler value: [0,4095] shows the range of the prescaler values to set in the edit field, in accordance to the following equation: [4] where : c = value of the capacitor expressed in nf; ckm = value fo the frequency of the clock master expressed in mhz; fullscale = value of the maximum range expressed in volts; charge_current = value of the generator of the current expressed in ua. the prescaler value can be set manually, according to the necessities of the maximum range of the user, or it can be calculated automatically by the visual five program by clicking on the box calculated. the visual five program will calculate the prescaler in such a manner that it has maximum resolution to the maximum voltage range, which is equal to 3v. the last box, 3v conv.time (ms) provides an indication of the time duration of the charge of the capacitor in order to reach 3 volts. n2550volt ? = n 0 3volt ? = n 0 0volt ? = n 255 3volt ? = p cnf () xckm mhz () xfullscale v () x10 3 ch e arg current m a () x2 resolution ----------------------------------------------------------------------------------------------------- 1 C =
5/10 AN1548 - application note main program the following figures show the various blocks that compose the program through which the measures of the a/d conversions can be performed. figure 5 shows the main program. figure 5. main program figure 6 shows the block of the irq_mask_0, which enables the interrupts of the comparator. figure 6. comparator interrupt enable
AN1548 - application note 6/10 the second block in the main program is represented by figure 7 and simply indicates the start of the an- alog comparator and takes into account the configuration set during the setting device configuration (fig- ure 4). figure 7. start analog comparator the last block in the main program is a small code that transfers the digital value n into port_a and port_c. the wait block sincronizes the digital value at the end of every conversion. if using an 8 bit resolution, the second code instruction in figure 8 can be omitted. figure 8. code for acquisition
7/10 AN1548 - application note hardware implementation schematic the schematic used to convert an analog signal in input to pb0 pin of the st52x440 micro into a digital signal that can be taken from the pins of port_a and port_c , which is shown in figure 9 below. figure 9. schematic vcc r2 47k
AN1548 - application note 8/10 measures the following section shows the measures of the analog comparator of the st52x440 microcontroller. the measures were performed at 8,10 and 12 bits changing the dimensions of the capacitors by 10,100,1000nf, internal current generators by 10,40,70ua and the frequency by 5,10,20mhz for each one of these resolutions. in order to provide an example, we will take into consideration only a few of these tests. the tests were performed at constant temperatures of around 25 celsius. figure 10. a/d conversion-8 bit figure 11. a/d conversion-10 bit
9/10 AN1548 - application note figure 12. a/d conversion - 12 bit notes: input volt = value of the analogic voltage applied at the input of the microcontroller; measure = measure of conversion taken from a logical analyzer on exit of the microcontroller; theoretic value = theoretical conversion of the input voltage, calculated by the following equation: [5] where: v(t) = tension applied in a certain instant in (0;3) volts; c = value of the capacitor connected to the microcontroller; p =prescaler t clk =period of the clock master i =value of the generator of current configured; n =theoretical conversion that should be released by the a/d converter conclusions in this application note we have presented the operation of the analog comparator of the st52x440 mi- crocontroller, a simple program to perform simple a/d conversion measures at variable resolution. the accuracy of the tests strongly depend on the measurement conditions. notable improvements can be ob- tained using particular precautions such as: bord low noise, operating range between 1 and 3 volts (max- imum linearity), digital filtering of conversions, etc. references [1] st52t440/e440 datasheet [2] visual five 5.0, stmicroelectronics, 2002 n vt () c ip1 + () t clk --------------------------------------------- - =
AN1548 - application note 10/10 full product information at http://www.st.com/five information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specification mentioned in this publication are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics products are not authorized for use as critical components in life support devices or systems without express written approval of stmicroelectronics. the st logo is a registered trademark of stmicroelectronics ? 2002 stmicroelectronics C printed in italy C all rights reserved stmicroelectronics group of companies australia - brazil - china - canada - finland - france - germany - hong kong - india - israel - italy - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - u.s.a. http://www.st.com


▲Up To Search▲   

 
Price & Availability of AN1548

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X